﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.Common;
using System.Data.SqlClient;
using System.Configuration;
using System.Collections;

/// <summary>
/// Summary description for MailCountLog
/// </summary>
/// 

namespace CE.Mail
{
    public class MailCountLog
    {
        //private string _applicationName;
        //public string ApplicationName
        //{
        //    get { return _applicationName; }
        //    set { _applicationName = value; }
        //}

        private string _conString = "";

        public MailCountLog()
        {
            _conString = ConfigurationManager.ConnectionStrings["CX_KBDBConnectionString"].ToString();
        }

        public void InsertMailCountLog(string applicationName, int emailCount)
        {
            SqlCommand _sqlCmd = null;
            SqlConnection _sqlConn = new SqlConnection();
            try
            {
                string isLive = ConfigurationManager.AppSettings["MailCountLive"];

                _sqlCmd = new SqlCommand();
                _sqlCmd.Connection = _sqlConn;
                _sqlConn.ConnectionString = _conString;
                _sqlCmd.CommandType = CommandType.StoredProcedure;
                _sqlCmd.CommandText = "sproctblGGEmailsLogInsertSingleItem";
                SqlParameter _p1 = new SqlParameter("@IsLive", isLive);
                _sqlCmd.Parameters.Add(_p1);
                _p1 = new SqlParameter("@ApplicationName", applicationName);
                _sqlCmd.Parameters.Add(_p1);
                _p1 = new SqlParameter("@EmailCount", emailCount);
                _sqlCmd.Parameters.Add(_p1);
                _sqlConn.Open();
                _sqlCmd.ExecuteNonQuery();
            }
            catch (Exception)
            {

            }
            finally
            {
                if (_sqlCmd != null)
                {
                    _sqlCmd = null;
                }

                if (_sqlConn.State != ConnectionState.Closed)
                {
                    _sqlConn.Close();
                    _sqlConn = null;
                }
            }
        }

    }
}
